<template>
  <!-- 面包屑 -->
  <el-breadcrumb :separator-icon="ArrowRight">
    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>商品管理</el-breadcrumb-item>
    <el-breadcrumb-item>商品分类</el-breadcrumb-item>
  </el-breadcrumb>
  <!-- 卡片 -->
  <el-card>
    <el-button type="primary">添加分类</el-button>
    <!-- 表格 -->
    <el-table :data="mygategories" border style="width: 100%" class="table">
      <el-table-column type="index" label="序号" width="60" />
      <el-table-column prop="cat_name" label="分类名称" />
      <el-table-column prop="cat_level" label="是否有效" />
      <el-table-column prop="goods_weight" label="排序" />
      <el-table-column label="操作" width="80" />
    </el-table>
    <el-pagination
        v-model:current-page="wang.pagenum"
        v-model:page-size="wang.pagesize"
        :page-sizes="[1, 3, 5, 10]"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
  </el-card>
</template>

<script setup lang="ts">
// 面包屑里的箭头
import { ArrowRight } from '@element-plus/icons-vue'
import { responseUserData } from '@/api/user/type'
import request from "@/util/request";
import { onMounted,ref} from 'vue';
import { ElMessage } from 'element-plus'

let mygategories = ref ([])
let total = ref(0)
const wang = ref({
  query: '',
  pagenum: 1,
  pagesize: 20
})
const mygategor = async () => {
  const { data,meta }: responseUserData = await request({
    url: `categories`,
    method: 'GET',
    params: wang.value,
  })
  if (meta.status !== 200) {
    return ElMessage.error('网络异常,稍后重试')
  }
console.log(data,meta)
mygategories.value = data.goods
ElMessage.success(meta.msg)
}

onMounted(() => {
  mygategor()
})

</script>

<style scoped>
.el-card {
  margin-top: 20px;
}

.table {
  margin-top: 20px;
}
</style>
